import React from 'react'
import '../css/headers.css'
import eventEmitter from '../event'


class Headers extends React.Component{
    constructor(props){
        super(props)
        this.state={

        }        
        this.add=(e)=>{
            if(e.keyCode==13){
                // console.log(e.target.value);
                let val=e.target.value
                e.target.value=''
                let obj={content:val,status:0}
                eventEmitter.emit('sendObj',obj)//发布自定义事件，带上要传的数据
            }
            
        }
    }
    render(){
        return(
            <div className='headers'>
                <div className="head-box">
                    <b className="logo">ToDoList</b>
                    <input type="text" className='input' placeholder='请输入待办事项' onKeyDown={this.add} />
                </div>
            </div>
        )
    }
}

export default Headers;